#!/usr/bin/ruby

##### Initialization #####
# PostgreSQL database
require "rubygems"
require "dbi"
require "logger"
require "date"
#require "postgres"

date = Time.now()#create time object

#error log creates a max of 10 logs 1mb large
    errorLog = Logger.new("logbase.log", 10, 1024000) #error log
    errorLog.level = Logger::DEBUG #INFO,WARN, and FATAL(use in release)
    
begin
  #connect to the PostgreSQL server
  db = DBI.connect("DBI:Pg:logbase:localhost", "postgres", "impression5")
  row = db.select_one("SELECT VERSION()")
  puts "Server Version: " + row[0]
rescue DBI::DatabaseError => e
  puts "An error occured"
  puts "Error code: #{e.err}"
  puts "Error message: #{e.errstr}"
  Error_log::errorLog.fatal(e)
ensure 
  db.disconnect if db
end

# Find log files directory (default /var/log)
logDirHash = Hash.new()
logDir = Dir.new("/var/log/")
logDir.each do ||
end

# Parse file each_line (log message)

# Parse each log entry to mysql

